package top.mataiji.manager.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.mataiji.manager.pojo.SlideShow;
import top.mataiji.manager.pojo.dtd.BookImgDtd;
import top.mataiji.manager.service.SlideShowService;
import top.mataiji.manager.util.Result;

import java.util.List;

/**
 * @Auther: zhaoss
 * @Date: 2021/4/4 - 04 - 04 - 20:58
 * @Description: top.mataiji.manager.controller
 * @version: 1.0
 */
@RestController
@RequestMapping("slideshow")
public class SlideShowController {


    @Autowired
    SlideShowService slideShowService;

    /**
     * 添加轮播图
     * @return
     */
    @RequestMapping("select")
    public List<SlideShow> selectSlideShow(){
        return slideShowService.selectSlideShow();
    }

    /**
     * 查询轮播图
     * @param bookimg
     * @return
     */
    @RequestMapping("add")
    public Result addSlideShow(BookImgDtd bookimg){
        List<String> imgs = bookimg.getBookimg();
        int i = slideShowService.addSlideShow(imgs);
        if(i>0){
            return Result.success("添加成功");
        }else {
            return Result.error("添加失败");
        }
    }

    /**
     * 查询轮播图
     * @param id
     * @return
     */
    @RequestMapping("delte")
    public Result deleteSlideShow(Integer id){
        int i = slideShowService.delectSlideShowById(id);
        if(i>0){
            return Result.success("删除成功");
        }else {
            return Result.error("删除失败");
        }
    }
}
